package com.zyj.study;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.apache.commons.collections4.map.MultiKeyMap;

import java.util.List;

public class MultiKeyMapSample {

    @Data
    @AllArgsConstructor
    private static class ApartmentPrice {
        private Integer mansionNum;//第几栋
        private String roomNum;//门牌号
        private Integer price;//价格
    }

    private static List<ApartmentPrice> apartments = List.of(
            new ApartmentPrice(1, "101", 100),
            new ApartmentPrice(1, "102", 150),
            new ApartmentPrice(1, "201", 90),
            new ApartmentPrice(1, "202", 160),
            new ApartmentPrice(2, "101", 80),
            new ApartmentPrice(2, "102", 130),
            new ApartmentPrice(2, "201", 80),
            new ApartmentPrice(2, "202", 140)
    );

    public static void main(String[] args) {
        MultiKeyMap<Object, Integer> multiKeyMap = new MultiKeyMap<>();
        for (ApartmentPrice apartment : apartments) {
            multiKeyMap.put(apartment.mansionNum, apartment.roomNum, apartment.price);
        }

        System.out.println(multiKeyMap.get(1, "201"));

    }
}
